package o;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import com.huawei.hms.framework.common.ContainerUtils;
import java.util.regex.Pattern;

public class emj {
    public static final CharSequence ˋ = ContainerUtils.FIELD_DELIMITER;
    private int ˊ;
    private boolean ˎ = true;

    class d implements TextWatcher {
        private EditText ˊ;
        private String ˎ;
        final /* synthetic */ emj ॱ;

        d(emj o_emj, EditText editText, String str) {
            this.ॱ = o_emj;
            this.ˊ = editText;
            this.ˎ = str;
        }

        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        public void afterTextChanged(Editable editable) {
            String obj = editable.toString();
            if (this.ॱ.ˎ && !obj.equals(this.ˎ)) {
                this.ॱ.ˎ = false;
                if (this.ॱ.ˊ <= 0 || obj.length() <= this.ॱ.ˊ) {
                    this.ˊ.setText("");
                    return;
                }
                Object substring = obj.substring(this.ॱ.ˊ);
                if (dof.ˋ(substring)) {
                    this.ˊ.setText("");
                    return;
                }
                this.ˊ.setText(substring);
                this.ˊ.setSelection(substring.length());
            }
        }
    }

    public emj(int i) {
        this.ˊ = i;
    }

    public void ॱ(EditText editText, String str) {
        editText.addTextChangedListener(new d(this, editText, str));
    }

    public static boolean ˎ(String str) {
        return Pattern.compile("^(0086|086|86|)1([\\d]{10})$").matcher(str).matches();
    }

    public static boolean ˋ(String str) {
        return Pattern.compile("^[0-9['\\-']]{4,50}$").matcher(str).matches();
    }

    public static String ˏ(String str) {
        String str2 = "";
        if (dof.ॱ(str) || !ˋ(str)) {
            return str2;
        }
        if (str.length() < 10) {
            return new StringBuilder(str.substring(0, 1)).append("***").append(str.substring(4)).toString();
        }
        int length = str.length() - 7;
        StringBuilder stringBuilder = new StringBuilder(str.substring(0, 3));
        for (int i = 0; i < length; i++) {
            stringBuilder.append("*");
        }
        stringBuilder.append(str.substring(str.length() - 4));
        return stringBuilder.toString();
    }

    public static String ˊ(String str) {
        String str2 = "";
        if (dof.ˋ(str)) {
            return str2;
        }
        if (ˎ(str)) {
            return eyk.ˎ(str);
        }
        return ˏ(str);
    }
}
